/**
 * @ClassName LC697
 * @Author ykx
 * @Date 2024/7/6 18:56
 * @Version 1.0
 */
public class LC697 {
    public static void main(String[] args) {
        LC697 lc697 = new LC697();
        System.out.println(lc697.findShortestSubArray(new int[]{1, 2, 2, 3, 1}));
    }

    public int findShortestSubArray(int[] nums) {
        int max = nums[0], min = nums[0];
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > max) {
                max = nums[i];
            }
            if (nums[i] < min) {
                min = nums[i];
            }
        }

        int[] count = new int[max - min + 1];
        int result = count[0];
        for (int i = 0; i < nums.length; i++) {
            count[nums[i] - min]++;
        }
        for (int i = 0; i < count.length; i++) {
            if (result < count[i]) {
                result = count[i];
            }
        }
        return result;

    }
}
